﻿// Inner Fire 游戏引擎库
// Lua绑定适配项目
//
// Copyright (c) 2025 by 尔西大帝. All rights reserved.
//
// 所属层级：应用层(4)
// 用于UI的Lua绑定适配。
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2025-04-30


#include "lua_manager.h"
#include "ui/manager/ui_manager.h"

using namespace ifire::ui;

namespace ifire::game{
  

static int Label_SetText(lua_State* L) {
  auto label = L_THIS(Label);
  label->SetText(L_STR(2));
  return 0;
}

static int Button_SetText(lua_State* L) {
  auto button = L_THIS(Button);
  button->SetText(L_STR(2));
  return 0;
}

static int Button_SetIcon(lua_State* L) {
  auto button = L_THIS(Button);
  button->SetIcon(L_STR(2));
  return 0;
}

static int Image_SetIcon(lua_State* L) {
  auto image = L_THIS(Image);
  image->SetImage(L_STR(2));
  return 0;
}

void register_lua_ui(lua_State* L, LuaManager* lua_manager) {
  

  // 注册UILabel动画机的元表
  luaL_Reg label_methods[] = {{"SetText", Label_SetText}, {NULL, NULL}};
  lua_register_metatable(L, "LabelMeta", label_methods);

  luaL_Reg button_methods[] = {
      {"SetText", Button_SetText}, {"SetIcon", Button_SetIcon}, {NULL, NULL}};
  lua_register_metatable(L, "ButtonMeta", button_methods);

  luaL_Reg image_methods[] = {{"SetIcon", Image_SetIcon}, {NULL, NULL}};
  lua_register_metatable(L, "ImageMeta", image_methods);

}

}